package com.wqr.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wqr.pojo.PasswordInfo;
import com.wqr.service.PasswordInfoService;


@Controller
public class PasswordInfoController extends BaseController {
	@Autowired
    public PasswordInfoService passwordInfoService;
	
	@RequestMapping("/managePasswordInfo")
	public String passwordInfo(Model model,@RequestParam(value = "pageIndex",required = false) String pageIndex,
			@RequestParam(value = "pageSize",required = false) String pageSize) throws Exception {
		List<PasswordInfo> list = passwordInfoService.list();
		model.addAttribute("itemList", list);
		page(list, model, pageSize, pageIndex);
	    return "managePasswordInfos"; 
	}
	
	@RequestMapping("/searchPasswordInfo")
	@ResponseBody
	public List<PasswordInfo> searchPasswordInfo(@RequestBody PasswordInfo passwordInfo) throws Exception {
		if(passwordInfo.getLoginName().length() == 0) {
			passwordInfo.setLoginName(null);
		}
		List<PasswordInfo> itemList = passwordInfoService.selectPasswordInfo(passwordInfo);
		
		return itemList;
	}
	
}
